/**
 * Created by 13576 on 2018/1/26.
 */
import config from 'config'
import httpFetch from 'share/httpFetch'

export default {

  //查询预算日记账头(复核)
  getBudgetJournalReCheckHeader(params) {
    return httpFetch.get(`${config.budgetUrl}/api/budget/journals/query/headers`, params)
  },

  //根据预算日记账编码查询预算日记账头行
  getBudgetJournalHeaderLine(journalCode) {
    return httpFetch.get(`${config.budgetUrl}/api/budget/journals/query/${journalCode}`)
  },

  //根据预算日记账编码查询预算日记账头
  getBudgetJournalHeaderDetil(journalCode) {
    return httpFetch.get(`${config.budgetUrl}/api/budget/journals/query/head/by/id?id=${journalCode}`)
  },

  //根据预算日记账编码查询预算日记账行
  getBudgetJournalLineDetil(code, params) {
    return httpFetch.get(`${config.budgetUrl}/api/budget/journals/query/line/by/header/id?headerId=${code}`, params)
  },

  //根据attachmentOID，查询附件
  getFileByAttachmentOID(params) {
    return httpFetch.get(`${config.budgetUrl}/api/budget/journals/getAttachmentDTOByOid`, params)
  },

  //根据维值查维度
  getDimensionByStructureId(structureId) {
    let params = {
      isEnabled: true,
      structureId
    };
    return httpFetch.get(`${config.budgetUrl}/api/budget/journals/getLayoutsByStructureId`, params)
  },

  //预算日记账通过（非工作流）
  passJournal(params) {
    return httpFetch.post(`${config.budgetUrl}/api/budget/journals/balance/create`, params)
  },

  //预算日记账驳回（非工作流）
  rejectJournal(params) {
    return httpFetch.post(`${config.budgetUrl}/api/budget/journals/rejectJournal`, params)
  },

  //计算总金额，拼接上币种的
  getTotalCurrencyAmount(code) {
    return httpFetch.get(`${config.budgetUrl}/api/budget/journals/get/line/amount/group/by/header/id?id=${code}`)
  }
}
